package com.xxx.encache.service;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * the class of advance
 *
 * <p>
 * .
 *
 * @author little_lunatic
 * @date 2025-01-08
 */
@Service
public class EhService {

    private  String key = "key";

    @Cacheable(value = "test", key = "#key")
    public String get(String key) {
        System.out.println("=========get operate db");
        return key;
    }

    @CachePut(value = "test", key = "#key")
    public String put(String key) {
        System.out.println("=========put operate db");
        key = key + ", hello world";
        return key;
    }

    @CacheEvict(value = "test", allEntries = true)
    public void clear() {
        System.out.println("clear");
    }
}
